<load target="js/page_admin.js" usecdn="true" />
<include target="header.html" />

<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/module/tpl/manage_selected'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
	<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>

<!-- 검색 -->
<form action="./" method="get" class="search x_input-append x_pull-right" style="margin-bottom:-28px">
	<input type="hidden" name="module" value="{$module}" />
	<input type="hidden" name="mid" value="{$mid}" />
	<input type="hidden" name="vid" value="{$vid}" />
	<input type="hidden" name="act" value="dispPageAdminContent" />
	<select name="search_target" id="search_target" style="margin-right:4px">
		<option value="s_mid" selected="selected"|cond="$search_target=='s_mid'">{$lang->mid}</option>
		<option value="s_browser_title" selected="selected"|cond="$search_target=='s_browser_title'">{$lang->browser_title}</option>
		<option cond="$module_category">{$lang->module_category}</option>
	</select>
	<select name="module_category_srl" title="{$lang->module_category}" cond="$module_category" style="margin-right:4px">
		<option loop="$module_category => $key,$val" value="{$key}" selected="selected"|cond="$module_category_srl==$key">{$val->title}</option>
	</select>
	<input type="search" name="search_keyword" title="Search" value="{htmlspecialchars($search_keyword)}" required style="width:150px" />
	<button class="x_btn x_btn-inverse" type="submit">{$lang->cmd_search}</button>
	<a href="{getUrl('','module',$module,'act',$act)}" class="x_btn">{$lang->cmd_cancel}</a>
</form>
<script>
jQuery(function($){
	$('#search_target').change(function(){
		var $this = $(this);
		if($this.find('>option:last-child').is(':selected')){
			$this.next('select').show().removeAttr('disabled').next('input[type="search"]').hide().attr('disabled','disabled');
		} else {
			$this.next('select').hide().attr('disabled','disabled').next('input[type="search"]').show().removeAttr('disabled');
		}
	}).change();
});
</script>

<!-- 목록 -->
<form action="./" method="get" id="fo_list">
<table class="x_table x_table-striped x_table-hover">
	<caption><strong>Total: {number_format($total_count)}, Page: {number_format($page)}/{number_format($total_page)}</strong></caption>
	<thead>
		<tr>
			<th scope="col">{$lang->no}</th>
			<th scope="col">{$lang->module_category}</th>
			<th scope="col">{$lang->page_type}</th>
			<th scope="col">{$lang->mid}</th>
			<th scope="col">{$lang->browser_title}</th>
			<th scope="col">{$lang->regdate}</th>
			<th scope="col">&nbsp;</th>
			<th scope="col"><input type="checkbox" /></th>
		</tr>
	</thead>
	<tbody>
		<!--@foreach($page_list as $no => $val)-->
		<tr class="row{$cycle_idx}">
			<td>{$no}</td>
			<td>
				<!--@if(!$val->module_category_srl)-->
				<!--@if($val->site_srl)-->
				{$lang->virtual_site}
				<!--@else-->
				{$lang->not_exists}
				<!--@end-->
				<!--@else-->
				{$module_category[$val->module_category_srl]->title}
				<!--@end-->
				</td>
			<td>{$val->page_type}</td>
			<td>{$val->mid}</td>
			<td><a href="{getSiteUrl($val->domain,'','mid',$val->mid)}" target="_blank">{$val->browser_title}</a></td>
			<td>{zdate($val->regdate,"Y-m-d")}</td>
			<td>
				<a href="{getUrl('act','dispPageAdminInfo','module_srl',$val->module_srl)}">{$lang->cmd_setup}</a>
				<i>|</i>
				<a href="{getUrl('','module','module','act','dispModuleAdminCopyModule','module_srl',$val->module_srl)}" onclick="popopen(this.href);return false;">{$lang->cmd_copy}</a>
				<i>|</i>
				<a href="{getUrl('act','dispPageAdminDelete','module_srl', $val->module_srl)}">{$lang->cmd_delete}</a>
				</td>
			<td><input type="checkbox" name="cart" value="{$val->module_srl}" class="selectedModule" data-mid="{$val->mid}" data-browser_title="{$val->browser_title}" /></td>
		</tr>
	<!--@end-->
	</tbody>
</table>

<div class="x_clearfix">
	<div class="x_btn-group x_pull-right">
		<a class="x_btn modalAnchor x_pull-right _manageSelected" href="#manageSelectedModule">{$lang->cmd_manage_selected_page}</a>
	</div>
</div>

</form>

<!-- 페이지 네비게이션 -->
<form cond="$page_navigation" action="./" class="x_pagination" no-error-return-url="true" style="margin:-36px 0 0 0">
	<input type="hidden" name="module" value="{$module}" />
	<input type="hidden" name="act" value="{$act}" />
	<input cond="$search_target" type="hidden" name="search_target" value="{$search_target}" />
	<input cond="$search_keyword" type="hidden" name="search_keyword" value="{$search_keyword}" />
	<ul>
		<li class="x_disabled"|cond="!$page || $page == 1"><a href="{getUrl('page', '')}">&laquo; {$lang->first_page}</a></li>

		<block cond="$page_navigation->first_page != 1 && $page_navigation->first_page + $page_navigation->page_count > $page_navigation->last_page - 1 && $page_navigation->page_count != $page_navigation->total_page">
			{@$isGoTo = true}
			<li>
				<a href="#goTo" data-toggle title="{$lang->cmd_go_to_page}">&hellip;</a>
				<span cond="$isGoTo" id="goTo" class="x_input-append">
					<input type="number" min="1" max="{$page_navigation->last_page}" required name="page" title="{$lang->cmd_go_to_page}" />
					<button type="submit" class="x_add-on">Go</button>
				</span>
			</li>
		</block>

<!--@while($page_no = $page_navigation->getNextPage())-->
		{@$last_page = $page_no}
		<li class="x_active"|cond="$page_no == $page"><a  href="{getUrl('page', $page_no)}">{$page_no}</a></li>
		<!--@end-->

		<block cond="$last_page != $page_navigation->last_page && $last_page + 1 != $page_navigation->last_page">
			{@$isGoTo = true}
			<li>
				<a href="#goTo" data-toggle title="{$lang->cmd_go_to_page}">&hellip;</a>
				<span cond="$isGoTo" id="goTo" class="x_input-append">
					<input type="number" min="1" max="{$page_navigation->last_page}" required name="page" title="{$lang->cmd_go_to_page}" />
					<button type="submit" class="x_add-on">Go</button>
				</span>
			</li>
			
		</block>

		<li class="x_disabled"|cond="$page == $page_navigation->last_page"><a href="{getUrl('page', $page_navigation->last_page)}" title="{$page_navigation->last_page}">{$lang->last_page} &raquo;</a></li>
	</ul>
</form>

{$selected_manage_content}

<script>
jQuery(function($){
	// Modal anchor activation
	var $docTable = $('#fo_list>table');
	$docTable.find(':checkbox').change(function(){
		var $modalAnchor = $('a.modalAnchor._manageSelected');
		if($docTable.find('tbody :checked').length == 0){
			$modalAnchor.removeAttr('href').addClass('x_disabled');
		} else {
			$modalAnchor.attr('href','#manageSelectedModule').removeClass('x_disabled');
		}
	}).change();
	// Button action
	$('a.modalAnchor').click(function(){
		if($docTable.find('tbody :checked').length == 0){
			$('body').css('overflow','auto');
			alert('{$lang->msg_not_selected_page}');
			return false;
		}
	});
});
</script>